package com.bd.wechat.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.bd.wechat.core.R;
import com.bd.wechat.entity.ShopFranchise;
import com.bd.wechat.entity.request.FranchiseApplyForRequest;
import com.bd.wechat.entity.request.FranchiseApproveRequest;
import com.bd.wechat.entity.request.MyRecordFranchisePageRequest;
import com.bd.wechat.entity.response.ShopFranchiseMyRecordResponse;
import com.bd.wechat.service.ShopFranchiseService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author linhs
 * @menu 小程序端
 * @since 2024-11-15
 */
@RestController
@RequestMapping("/wechat/franchise")
public class ShopFranchiseController {

    @Resource
    private ShopFranchiseService shopFranchiseService;

    /**
     * 我的申请记录
     *
     * @param pageRequest
     * @return
     */
    @GetMapping("/pageMyRecord/{pageNum}/{pageSize}")
    public R<Page<ShopFranchiseMyRecordResponse>> pageMyRecord(@PathVariable("pageNum") Integer pageNum,
                                                               @PathVariable("pageSize") Integer pageSize,
                                                               MyRecordFranchisePageRequest pageRequest) {
        Page<ShopFranchiseMyRecordResponse> page = shopFranchiseService.pageMyRecord(pageNum, pageSize, pageRequest);
        return R.ok(page);
    }


    /**
     * 发起申请
     *
     * @param applyForRequest
     * @return
     */
    @PostMapping("/applyFor")
    public R<Page<ShopFranchise>> apcplyFor(@Valid @RequestBody FranchiseApplyForRequest applyForRequest) {
        shopFranchiseService.applyFor(applyForRequest);
        return R.ok();
    }


}

